-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(token-search): fix token search results #3607
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
matched = t | ||
// There should ever be only 1 token with a given address | ||
// There can be multiple with the same symbol | ||
matched.push(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix for missing entries.
Now all matches are collected.
@@ -7,6 +7,6 @@ import { TokensMap } from '../types' | |||
*/ | |||
export function tokenMapToListWithLogo(tokenMap: TokensMap): TokenWithLogo[] { | |||
return Object.values(tokenMap) | |||
.sort((a, b) => (a.symbol > b.symbol ? 1 : -1)) | |||
.sort((a, b) => (a.symbol === b.symbol ? 0 : a.symbol > b.symbol ? 1 : -1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix for sorting.
We were not accounting for when symbols are identical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups we missed this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, localeCompare is what we should use for strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! I didn't even know about it
<h4>Favourite tokens</h4> | ||
<InfoIcon iconType="help" content="Your favourite saved tokens. Edit this list in your account page." /> | ||
<h4>Favorite tokens</h4> | ||
<InfoIcon iconType="help" content="Your favorite saved tokens. Edit this list in your account page." /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional request by Alex to update the spelling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the 🕵️ and fix!
@@ -7,6 +7,6 @@ import { TokensMap } from '../types' | |||
*/ | |||
export function tokenMapToListWithLogo(tokenMap: TokensMap): TokenWithLogo[] { | |||
return Object.values(tokenMap) | |||
.sort((a, b) => (a.symbol > b.symbol ? 1 : -1)) | |||
.sort((a, b) => (a.symbol === b.symbol ? 0 : a.symbol > b.symbol ? 1 : -1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups we missed this!
@@ -7,6 +7,6 @@ import { TokensMap } from '../types' | |||
*/ | |||
export function tokenMapToListWithLogo(tokenMap: TokensMap): TokenWithLogo[] { | |||
return Object.values(tokenMap) | |||
.sort((a, b) => (a.symbol > b.symbol ? 1 : -1)) | |||
.sort((a, b) => a.symbol.localeCompare(b.symbol)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
funny, i just came to suggest this (use localeCompare), and I saw it was done moments ago!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got to it when reading https://levelup.gitconnected.com/cross-browser-crazy-44e90d61b204
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
44768fa
to
6e3a0a0
Compare
Summary
Fixes #3599
There were 2 issues with token search
Due to default browsers' sorting behaviour, the results were different when the symbols were identical.
This is the case for StaFi and Rocket Poll Eth.
In the displayed list of matches, we picked the one matching exactly the search terms, by address or symbol.
Turns out symbol is not unique, so we were silently dropping everything but the last match.
This is the case for both tokens above, as well as COW Protocol Token and cowfarm.finance
To Test
reth
cow